
var _util = require('util/util.js');
const { getServerURL, request } = require('../util/util');

var _account_service = {
    checkLogin: function (resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/get_login_account_info'),
            method: "POST",
            success: resolve,
            error: reject,

        });
    },
    login: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/login'),
            data: account,
            method: "POST",
            success: resolve,
            error: reject,

        });
    },
    loginByPhone: function (data, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/loginByPhone'),
            data: data,
            method: "POST",
            success: resolve,
            error: reject,

        });
    },
    sendCode: function (data, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/sendCode'),
            data: data,
            method: "GET",
            success: resolve,
            error: reject,

        });
    },
    isUsernameExist: function (username, resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('account/is_username_exist/') + username,
            method: "GET",
            success: resolve,
            error: reject,
        });
    },
    logOut: function (resolve, reject) {
        _util.request({

            //后端的url
            url: _util.getServerURL('account/logOut'),
            method: "GET",
            success: resolve,
            error: reject,
        });
    },
    signUp: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/signup'),
            data: account,
            method: "POST",
            success: resolve,
            error: reject,
        })
    },
    updatePassword: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/password_reset'),
            data: account,
            method: "POST",
            success: resolve,
            error: reject,
        })

    },
    update: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('account/update_info'),
            data: account,
            method: "POST",
            success: resolve,
            error: reject,
        })
    },


};
module.exports = _account_service;